package cn.itcast.hotel.mq;

import cn.itcast.hotel.constants.HotelMqConstants;
import cn.itcast.hotel.service.IHotelService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author Broxigar
 * @Date 2022/2/15 22:21
 * @Version 1.0
 */

@Component
public class HotelListener {

    @Autowired
    private IHotelService hotelService;


    /**
     * 监听新增或修改的业务
     * @param id
     */

    @RabbitListener(queues = HotelMqConstants.HOTEL_INSERT_QUEUE)
    public void listenHotelInsertOrUpdate(Long id) {
        hotelService.insertById(id);

    }


    /**
     * 监听删除的业务
     * @param id
     */
    @RabbitListener(queues = HotelMqConstants.HOTEL_DELETE_QUEUE)
    public void listenHotelDelete(Long id) {
        hotelService.deleteById(id);

    }




}
